# Maintainer: David Runge <dvzrv@archlinux.org>

_name=GxPlugins.lv2
_othername=gxplugins
pkgname=gxplugins.lv2
pkgver=1.0
pkgrel=1
pkgdesc="A set of extra lv2 plugins from the guitarix project"
arch=(loong64 x86_64)
url="https://github.com/brummer10/gxplugins.lv2"
license=(GPL3)
groups=(lv2-plugins)
# TODO: devendor zita-resampler if possible
depends=(cairo gcc-libs glibc libx11 lv2-host)
makedepends=(lv2)
checkdepends=(lv2lint)
source=($url/releases/download/v$pkgver/${_othername}_${pkgver}_src.tar.bz2)
sha512sums=('590b5cdc662428260b64afa55aaed8632f7b8ab3307a19daff68b59c5de8b07d874408a31c0180f7195bbca06b71e8c907fbbb5db91cdc9e8c7e6519123687bb')
b2sums=('22674f42832a37f97ce93b75201167707d517e5ddda87dbbb4a87d12fca62d9691e24074eceea58db387d5e7e857673bcae0ae56fcbb9c3535857e6e864cc120')

prepare() {
  # there are lots of unneeded files: 
  find $_name -type d -iname "*.git/*" -exec rm -frv {} +
}

build() {
  make -C $_name
}

check() {
  local _plugin_name
  local base_url="http://guitarix.sourceforge.net/plugins"
  declare -A _urls=(
    ["GxVoodoFuzz.lv2"]="gx_voodoo_#_voodoo_"
    ["GxVmk2.lv2"]="gx_vmk2d_#_vmk2d_"
    ["GxVintageFuzzMaster.lv2"]="gx_vfm_#_vfm_"
    ["GxValveCaster.lv2"]="gx_valvecaster_#_valvecaster_"
    ["GxVBassPreAmp.lv2"]="gx_voxbass_#_voxbass_"
    ["GxUltraCab.lv2"]="gx_ultracab_#_ultracab_"
    ["GxUVox720k.lv2"]="gx_uvox_#_uvox_"
    ["GxTubeDistortion.lv2"]="gx_TubeDistortion_#_TubeDistortion_"
    ["GxToneMachine.lv2"]="gx_tonemachine_#_tonemachine_"
    ["GxTimRay.lv2"]="gx_timray_#_timray_"
    ["GxSuppaToneBender.lv2"]="gx_vstb_#_vstb_"
    ["GxSupersonic.lv2"]="gx_supersonic_#_supersonic_"
    ["GxSuperFuzz.lv2"]="gx_sfp_#_sfp_"
    ["GxSunFace.lv2"]="gx_SunFace_#_SunFace_"
    ["GxSlowGear.lv2"]="gx_slowgear_#_slowgear_"
    ["GxSloopyBlue.lv2"]="gx_sloopyblue_#_sloopyblue_"
    ["GxShakaTube.lv2"]="gx_shakatube_#_shakatube_"
    ["GxSaturator.lv2"]="gx_saturate_#_saturate_"
    ["GxSVT.lv2"]="gx_ampegsvt_#_ampegsvt_"
    ["GxSD2Lead.lv2"]="gx_sd2lead_#_sd2lead_"
    ["GxSD1.lv2"]="gx_sd1sim_#_sd1sim_"
    ["GxQuack.lv2"]="gx_quack_#_quack_"
    ["GxPlexi.lv2"]="gx_plexi_#_plexi_"
    ["GxMicroAmp.lv2"]="gx_MicroAmp_#_MicroAmp_"
    ["GxLuna.lv2"]="gx_luna_#_luna_"
    ["GxLiquidDrive.lv2"]="gx_liquiddrive_#_liquiddrive_"
    ["GxKnightFuzz.lv2"]="gx_KnightFuzz_#_KnightFuzz_"
    ["GxHyperion.lv2"]="gx_hyperion_#_hyperion_"
    ["GxHotBox.lv2"]="gx_hotbox_#_hotbox_"
    ["GxHeathkit.lv2"]="gx_Heathkit_#_Heathkit_"
    ["GxGuvnor.lv2"]="gx_guvnor_#_guvnor_"
    ["GxFz1s.lv2"]="gx_maestro_fz1s_#_maestro_fz1s_"
    ["GxFz1b.lv2"]="gx_maestro_fz1b_#_maestro_fz1b_"
    ["GxEternity.lv2"]="gx_eternity_#_eternity_"
    ["GxEpic.lv2"]="gx_epic_#_epic_"
    ["GxDOP250.lv2"]="gx_DOP250_#_DOP250_"
    ["GxCreamMachine.lv2"]="gx_CreamMachine_#_CreamMachine_"
    ["GxClubDrive.lv2"]="gx_clubdrive_#_clubdrive_"
    ["GxBottleRocket.lv2"]="gx_bottlerocket_#_bottlerocket_"
    ["GxBoobTube.lv2"]="gx_boobtube_#_boobtube_"
    ["GxBlueAmp.lv2"]="gx_blueamp_#_blueamp_"
    ["GxBaJaTubeDriver.lv2"]="gx_bajatubedriver_#_bajatubedriver_"
    ["GxAxisFace.lv2"]="gx_AxisFace_#_AxisFace_"
  )
  declare -A _names=(
    ["GxVoodoFuzz.lv2"]="gx_voodoo.lv2"
    ["GxVmk2.lv2"]="gx_vmk2d.lv2"
    ["GxVintageFuzzMaster.lv2"]="gx_vfm.lv2"
    ["GxValveCaster.lv2"]="gx_valvecaster.lv2"
    ["GxVBassPreAmp.lv2"]="gx_voxbass.lv2"
    ["GxUltraCab.lv2"]="gx_ultracab.lv2"
    ["GxUVox720k.lv2"]="gx_uvox.lv2"
    ["GxTubeDistortion.lv2"]="gx_TubeDistortion.lv2"
    ["GxToneMachine.lv2"]="gx_tonemachine.lv2"
    ["GxTimRay.lv2"]="gx_timray.lv2"
    ["GxSuppaToneBender.lv2"]="gx_vstb.lv2"
    ["GxSupersonic.lv2"]="gx_supersonic.lv2"
    ["GxSuperFuzz.lv2"]="gx_sfp.lv2"
    ["GxSunFace.lv2"]="gx_SunFace.lv2"
    ["GxSlowGear.lv2"]="gx_slowgear.lv2"
    ["GxSloopyBlue.lv2"]="gx_sloopyblue.lv2"
    ["GxShakaTube.lv2"]="gx_shakatube.lv2"
    ["GxSaturator.lv2"]="gx_saturate.lv2"
    ["GxSVT.lv2"]="gx_ampegsvt.lv2"
    ["GxSD2Lead.lv2"]="gx_sd2lead.lv2"
    ["GxSD1.lv2"]="gx_sd1sim.lv2"
    ["GxQuack.lv2"]="gx_quack.lv2"
    ["GxPlexi.lv2"]="gx_plexi.lv2"
    ["GxMicroAmp.lv2"]="gx_MicroAmp.lv2"
    ["GxLuna.lv2"]="gx_luna.lv2"
    ["GxLiquidDrive.lv2"]="gx_liquiddrive.lv2"
    ["GxKnightFuzz.lv2"]="gx_KnightFuzz.lv2"
    ["GxHyperion.lv2"]="gx_hyperion.lv2"
    ["GxHotBox.lv2"]="gx_hotbox.lv2"
    ["GxHeathkit.lv2"]="gx_Heathkit.lv2"
    ["GxGuvnor.lv2"]="gx_guvnor.lv2"
    ["GxFz1s.lv2"]="gx_maestro_fz1s.lv2"
    ["GxFz1b.lv2"]="gx_maestro_fz1b.lv2"
    ["GxEternity.lv2"]="gx_eternity.lv2"
    ["GxEpic.lv2"]="gx_epic.lv2"
    ["GxDOP250.lv2"]="gx_DOP250.lv2"
    ["GxCreamMachine.lv2"]="gx_CreamMachine.lv2"
    ["GxClubDrive.lv2"]="gx_clubdrive.lv2"
    ["GxBottleRocket.lv2"]="gx_bottlerocket.lv2"
    ["GxBoobTube.lv2"]="gx_boobtube.lv2"
    ["GxBlueAmp.lv2"]="gx_blueamp.lv2"
    ["GxBaJaTubeDriver.lv2"]="gx_bajatubedriver.lv2"
    ["GxAxisFace.lv2"]="gx_AxisFace.lv2"
  )

  for _plugin_name in "${!_names[@]}"; do
    lv2lint -Mpack -I $_name/$_plugin_name/${_names[$_plugin_name]}/ "$base_url/${_urls[$_plugin_name]}" || echo "https://github.com/brummer10/GxPlugins.lv2/issues/36"
  done
}

package() {
  make DESTDIR="$pkgdir" install -C $_name
  install -vDm 644 $_name/README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
